package com.example.demo.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.example.demo.entity.Menu;
import com.example.demo.mapper.MenuMapper;
import com.example.demo.service.IMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cdn
 * @since 2025-04-29
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {


    public MenuServiceImpl() {
        System.out.println("MenuServiceImpl");
    }




    /**
     * @author 蔡定努
     */
    public String aa() {
        System.out.println(11111111111L);
        Menu menu = baseMapper.selectById(1);
        return menu.getName();
    }


    public static void main(String[] args) {
        Menu menu = new Menu();
        menu.setId(0);
        menu.setName("");
        menu.setParentId(0);
        menu.setUserId(0);
        menu.setContent("");
        menu.setTenantId(0);


        HashMap<String, Object> map = new HashMap<>();
        Class<? extends Menu> aClass = menu.getClass();
        Field[] declaredFields = aClass.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            declaredField.setAccessible(true);
            try {
                Object o = declaredField.get(menu);
                map.put(declaredField.getName(), o);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        System.out.println(map);
    }
}
